from biz_code.d import d60550001_employee_comm as db
from biz_code.component.comm import public_utils


async def a60550001_employee_login(request):
    result = {"code": 0, "msg": "登录成功"}
    params = request.json
    params = params["params"]
    try:
        # 显性取参, False 不是必填， True 必填
        params = {
            "employee_number": public_utils.get_params(params, "employee_number", "", True),
            "password": public_utils.get_params(params, "password", "", True),
        }
        conn_id = request.app.auto_commit_mysql_conn
        result["data"] = await db.employee_qry(params, conn_id)
        result["data"] = public_utils.generate_jwt(result["data"][0])


    except Exception as error:
        print(" error : ", error)
        result["code"] = 200
        result["msg"] = "登录错误： " + error.__str__()
    finally:
        return result


function = a60550001_employee_login
